package cn.darksoul3.springcloud.controller;

import cn.darksoul3.common.result.GlobalCodeMsgEnum;
import cn.darksoul3.common.result.ObjectResult;
import cn.darksoul3.springcloud.core.api.TickSvc;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
public class tik {

    private final TickSvc tickSvc;
    private final DiscoveryClient discoveryClient;

    @Autowired
    public tik(TickSvc tickSvc, DiscoveryClient discoveryClient) {
        this.tickSvc = tickSvc;
        this.discoveryClient = discoveryClient;
    }


    @GetMapping(value = "/tik")
    public ObjectResult tik(){
        log.info("this is tik");
        return tickSvc.tick();
    }

    @GetMapping(value = "/discovery")
    public ObjectResult discovery(){
        log.info("this is discovery");
        return ObjectResult.succeed(this.discoveryClient);
    }

    @GetMapping(value = "/tout")
    public ObjectResult tout() throws InterruptedException {
        log.info("this is tout");
        return tickSvc.tout();
    }

    @GetMapping(value = "/tbreak/{id}")
    public ObjectResult tBreak(@PathVariable("id")Integer id){
        log.info("this is t break");
        return tickSvc.tBreak(id);
    }


}
